package com.ray.server;
import java.io.IOException;
import java.io.InputStream;

import com.ray.basic.BASIC;
import com.ray.server.RW_myQ;


public class Server_in  implements Runnable {
	private InputStream in;
	private String clientid;
 	public Server_in(InputStream in, String clientid){
		this.in=in;
		this.clientid=clientid;
	}
	public void run(){
		boolean status=true;
		while (status){
			byte [] receiveBuf=new byte[BASIC.get_BUFSIZE()];
			int length=0;
			try {
				length = in.read(receiveBuf);
				String receive= new String(receiveBuf,0,length);
				receive=BASIC.unpack(receive);//unpack package
				System.out.println("Server_in::"+clientid+":"+receive);
				status=new RW_myQ().put(receive, clientid);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				break;
			}
		}
	}
}
